package com.gaeainfo.modules.dic.code.controller;

import com.gaeainfo.framework.core.basic.dto.BaseResponseDto;
import com.gaeainfo.framework.core.utils.common.GaeaCommonUtil;
import com.gaeainfo.modules.dic.code.service.DicCodeService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created by Caven on 2018/7/14.
 */
@Controller
@RequestMapping("rest/dic-code")
public class DicCodeController {

    private final Logger logger = LoggerFactory.getLogger(getClass());

    @Autowired
    private DicCodeService dicCodeService;

    @ResponseBody
    @RequestMapping("get-dic-code")
    public BaseResponseDto getDicCode() {
        try {
            return BaseResponseDto.successtData(dicCodeService.getDicCode());
        } catch (Exception e) {
            logger.error(GaeaCommonUtil.getStackTrace(e));
            return BaseResponseDto.exception(e);
        }

    }

    @ResponseBody
    @RequestMapping("get-alarm-type")
    public BaseResponseDto getAlarmType() {
        try {
            return BaseResponseDto.successtData(dicCodeService.getAlarmType());
        } catch (Exception e) {
            logger.error(GaeaCommonUtil.getStackTrace(e));
            return BaseResponseDto.exception(e);
        }

    }

    @ResponseBody
    @RequestMapping("get-space-type")
    public BaseResponseDto getSpaceType() {
        try {
            return BaseResponseDto.successtData(dicCodeService.getSpaceType());
        } catch (Exception e) {
            logger.error(GaeaCommonUtil.getStackTrace(e));
            return BaseResponseDto.exception(e);
        }

    }

    @ResponseBody
    @RequestMapping("get-result-type")
    public BaseResponseDto getResultType() {
        try {
            return BaseResponseDto.successtData(dicCodeService.getResultType());
        } catch (Exception e) {
            logger.error(GaeaCommonUtil.getStackTrace(e));
            return BaseResponseDto.exception(e);
        }

    }

}
